﻿#pragma once

#define WIN32_LEAN_AND_MEAN    // 从 Windows 头文件中排除极少使用的内容

#include <stdio.h>
#include <memory>
#include <string>
#include <vector>
#include <map>
#include <windows.h>
#include <time.h>
using namespace std;

#ifdef  XC_MOUDLE

#endif

#include "include\mysql.h"
//#pragma comment(lib,"lib/libmysql.lib")  

//@模块名称  数据库mysql
//@版本  1.0  
//@日期  2020-11-20
//@作者  XCGUI  
//@模块备注 数据库mysql


/*@声明
//@lib "lib\libmysql.lib"

struct MYSQL{};

enum mysql_option
{
  MYSQL_OPT_CONNECT_TIMEOUT, MYSQL_OPT_COMPRESS, MYSQL_OPT_NAMED_PIPE,
  MYSQL_INIT_COMMAND, MYSQL_READ_DEFAULT_FILE, MYSQL_READ_DEFAULT_GROUP,
  MYSQL_SET_CHARSET_DIR, MYSQL_SET_CHARSET_NAME, MYSQL_OPT_LOCAL_INFILE,
  MYSQL_OPT_PROTOCOL, MYSQL_SHARED_MEMORY_BASE_NAME, MYSQL_OPT_READ_TIMEOUT,
  MYSQL_OPT_WRITE_TIMEOUT, MYSQL_OPT_USE_RESULT,
  MYSQL_OPT_USE_REMOTE_CONNECTION, MYSQL_OPT_USE_EMBEDDED_CONNECTION,
  MYSQL_OPT_GUESS_CONNECTION, MYSQL_SET_CLIENT_IP, MYSQL_SECURE_AUTH,
  MYSQL_REPORT_DATA_TRUNCATION, MYSQL_OPT_RECONNECT,
  MYSQL_OPT_SSL_VERIFY_SERVER_CERT, MYSQL_PLUGIN_DIR, MYSQL_DEFAULT_AUTH,
  MYSQL_OPT_BIND,
  MYSQL_OPT_SSL_KEY, MYSQL_OPT_SSL_CERT,
  MYSQL_OPT_SSL_CA, MYSQL_OPT_SSL_CAPATH, MYSQL_OPT_SSL_CIPHER,
  MYSQL_OPT_SSL_CRL, MYSQL_OPT_SSL_CRLPATH,
  MYSQL_OPT_CONNECT_ATTR_RESET, MYSQL_OPT_CONNECT_ATTR_ADD,
  MYSQL_OPT_CONNECT_ATTR_DELETE,
  MYSQL_SERVER_PUBLIC_KEY,
  MYSQL_ENABLE_CLEARTEXT_PLUGIN,
  MYSQL_OPT_CAN_HANDLE_EXPIRED_PASSWORDS,
  MYSQL_OPT_SSL_ENFORCE,
  MYSQL_OPT_MAX_ALLOWED_PACKET, MYSQL_OPT_NET_BUFFER_LENGTH,
  MYSQL_OPT_TLS_VERSION,
  MYSQL_OPT_SSL_MODE
};

struct MYSQL_PARAMETERS
{
  unsigned long *p_max_allowed_packet;
  unsigned long *p_net_buffer_length;
  void *extension;
};

MYSQL_PARAMETERS *WINAPI mysql_get_parameters(void);
int WINAPI mysql_server_init(int argc, char **argv, char **groups);
void WINAPI mysql_server_end(void);
my_bool WINAPI mysql_thread_init(void);
void WINAPI mysql_thread_end(void);

my_ulonglong WINAPI mysql_num_rows(MYSQL_RES *res);
unsigned int WINAPI mysql_num_fields(MYSQL_RES *res);
my_bool WINAPI mysql_eof(MYSQL_RES *res);
MYSQL_FIELD *WINAPI mysql_fetch_field_direct(MYSQL_RES *res, unsigned int fieldnr);
MYSQL_FIELD * WINAPI mysql_fetch_fields(MYSQL_RES *res);
MYSQL_ROW_OFFSET WINAPI mysql_row_tell(MYSQL_RES *res);
MYSQL_FIELD_OFFSET WINAPI mysql_field_tell(MYSQL_RES *res);

unsigned int WINAPI mysql_field_count(MYSQL *mysql);
my_ulonglong WINAPI mysql_affected_rows(MYSQL *mysql);
my_ulonglong WINAPI mysql_insert_id(MYSQL *mysql);
unsigned int WINAPI mysql_errno(MYSQL *mysql);
const char * WINAPI mysql_error(MYSQL *mysql);
const char *WINAPI mysql_sqlstate(MYSQL *mysql);
unsigned int WINAPI mysql_warning_count(MYSQL *mysql);
const char * WINAPI mysql_info(MYSQL *mysql);
unsigned long WINAPI mysql_thread_id(MYSQL *mysql);
const char * WINAPI mysql_character_set_name(MYSQL *mysql);
int          WINAPI mysql_set_character_set(MYSQL *mysql, const char *csname);

MYSQL *		WINAPI mysql_init(MYSQL *mysql);
my_bool		WINAPI mysql_ssl_set(MYSQL *mysql, const char *key, const char *cert, const char *ca, const char *capath, const char *cipher);
const char *    WINAPI mysql_get_ssl_cipher(MYSQL *mysql);
my_bool		WINAPI mysql_change_user(MYSQL *mysql, const char *user, const char *passwd, const char *db);
MYSQL *		WINAPI mysql_real_connect(MYSQL *mysql, const char *host, const char *user, const char *passwd, const char *db, unsigned int port, const char *unix_socket, unsigned long clientflag);
int		WINAPI mysql_select_db(MYSQL *mysql, const char *db);
int		WINAPI mysql_query(MYSQL *mysql, const char *q);
int		WINAPI mysql_send_query(MYSQL *mysql, const char *q, unsigned long length);
int		WINAPI mysql_real_query(MYSQL *mysql, const char *q, unsigned long length);
MYSQL_RES *     WINAPI mysql_store_result(MYSQL *mysql);
MYSQL_RES *     WINAPI mysql_use_result(MYSQL *mysql);

void  WINAPI mysql_get_character_set_info(MYSQL *mysql, MY_CHARSET_INFO *charset);

int WINAPI mysql_session_track_get_first(MYSQL *mysql, enum enum_session_state_type type, const char **data, size_t *length);
int WINAPI mysql_session_track_get_next(MYSQL *mysql, enum enum_session_state_type type, const char **data, size_t *length);

//void mysql_set_local_infile_handler(MYSQL *mysql, int (*local_infile_init)(void **, const char *, void *),    int (*local_infile_read)(void *, char *, unsigned int),  void (*local_infile_end)(void *), int (*local_infile_error)(void *, char*, unsigned int), void *);

void mysql_set_local_infile_default(MYSQL *mysql);

int		WINAPI mysql_shutdown(MYSQL *mysql, enum mysql_enum_shutdown_level  shutdown_level);
int		WINAPI mysql_dump_debug_info(MYSQL *mysql);
int		WINAPI mysql_refresh(MYSQL *mysql, unsigned int refresh_options);
int		WINAPI mysql_kill(MYSQL *mysql,unsigned long pid);
int		WINAPI mysql_set_server_option(MYSQL *mysql, enum enum_mysql_set_option option);
int		WINAPI mysql_ping(MYSQL *mysql);
const char *	WINAPI mysql_stat(MYSQL *mysql);
const char *	WINAPI mysql_get_server_info(MYSQL *mysql);
const char *	WINAPI mysql_get_client_info(void);
unsigned long	WINAPI mysql_get_client_version(void);
const char *	WINAPI mysql_get_host_info(MYSQL *mysql);
unsigned long	WINAPI mysql_get_server_version(MYSQL *mysql);
unsigned int	WINAPI mysql_get_proto_info(MYSQL *mysql);
MYSQL_RES *	WINAPI mysql_list_dbs(MYSQL *mysql,const char *wild);
MYSQL_RES *	WINAPI mysql_list_tables(MYSQL *mysql,const char *wild);
MYSQL_RES *	WINAPI mysql_list_processes(MYSQL *mysql);
int		WINAPI mysql_options(MYSQL *mysql,enum mysql_option option,const void *arg);
int		WINAPI mysql_options4(MYSQL *mysql,enum mysql_option option, const void *arg1, const void *arg2);
int             WINAPI mysql_get_option(MYSQL *mysql, enum mysql_option option, const void *arg);
void		WINAPI mysql_free_result(MYSQL_RES *result);
void		WINAPI mysql_data_seek(MYSQL_RES *result, my_ulonglong offset);
MYSQL_ROW_OFFSET WINAPI mysql_row_seek(MYSQL_RES *result,	MYSQL_ROW_OFFSET offset);
MYSQL_FIELD_OFFSET WINAPI mysql_field_seek(MYSQL_RES *result, MYSQL_FIELD_OFFSET offset);
MYSQL_ROW	WINAPI mysql_fetch_row(MYSQL_RES *result);
unsigned long * WINAPI mysql_fetch_lengths(MYSQL_RES *result);
MYSQL_FIELD *	WINAPI mysql_fetch_field(MYSQL_RES *result);
MYSQL_RES *     WINAPI mysql_list_fields(MYSQL *mysql, const char *table, const char *wild);
unsigned long	WINAPI mysql_escape_string(char *to,const char *from, unsigned long from_length);
unsigned long	WINAPI mysql_hex_string(char *to,const char *from, unsigned long from_length);
unsigned long WINAPI mysql_real_escape_string(MYSQL *mysql, char *to,const char *from,unsigned long length);
unsigned long WINAPI mysql_real_escape_string_quote(MYSQL *mysql, char *to, const char *from, unsigned long length, char quote);
void          WINAPI mysql_debug(const char *debug);
void          WINAPI myodbc_remove_escape(MYSQL *mysql,char *name);
unsigned int  WINAPI mysql_thread_safe(void);
my_bool       WINAPI mysql_embedded(void);
my_bool       WINAPI mysql_read_query_result(MYSQL *mysql);
int           WINAPI mysql_reset_connection(MYSQL *mysql);

//-----------------------------
MYSQL_STMT * WINAPI mysql_stmt_init(MYSQL *mysql);
int WINAPI mysql_stmt_prepare(MYSQL_STMT *stmt, const char *query,unsigned long length);
int WINAPI mysql_stmt_execute(MYSQL_STMT *stmt);
int WINAPI mysql_stmt_fetch(MYSQL_STMT *stmt);
int WINAPI mysql_stmt_fetch_column(MYSQL_STMT *stmt, MYSQL_BIND *bind_arg, unsigned int column, unsigned long offset);
int WINAPI mysql_stmt_store_result(MYSQL_STMT *stmt);
unsigned long WINAPI mysql_stmt_param_count(MYSQL_STMT * stmt);
my_bool WINAPI mysql_stmt_attr_set(MYSQL_STMT *stmt, enum enum_stmt_attr_type attr_type, const void *attr);
my_bool WINAPI mysql_stmt_attr_get(MYSQL_STMT *stmt, enum enum_stmt_attr_type attr_type, void *attr);
my_bool WINAPI mysql_stmt_bind_param(MYSQL_STMT * stmt, MYSQL_BIND * bnd);
my_bool WINAPI mysql_stmt_bind_result(MYSQL_STMT * stmt, MYSQL_BIND * bnd);
my_bool WINAPI mysql_stmt_close(MYSQL_STMT * stmt);
my_bool WINAPI mysql_stmt_reset(MYSQL_STMT * stmt);
my_bool WINAPI mysql_stmt_free_result(MYSQL_STMT *stmt);
my_bool WINAPI mysql_stmt_send_long_data(MYSQL_STMT *stmt, unsigned int param_number, const char *data, unsigned long length);
MYSQL_RES *WINAPI mysql_stmt_result_metadata(MYSQL_STMT *stmt);
MYSQL_RES *WINAPI mysql_stmt_param_metadata(MYSQL_STMT *stmt);
unsigned int WINAPI mysql_stmt_errno(MYSQL_STMT * stmt);
const char *WINAPI mysql_stmt_error(MYSQL_STMT * stmt);
const char *WINAPI mysql_stmt_sqlstate(MYSQL_STMT * stmt);
MYSQL_ROW_OFFSET WINAPI mysql_stmt_row_seek(MYSQL_STMT *stmt, MYSQL_ROW_OFFSET offset);
MYSQL_ROW_OFFSET WINAPI mysql_stmt_row_tell(MYSQL_STMT *stmt);
void WINAPI mysql_stmt_data_seek(MYSQL_STMT *stmt, my_ulonglong offset);
my_ulonglong WINAPI mysql_stmt_num_rows(MYSQL_STMT *stmt);
my_ulonglong WINAPI mysql_stmt_affected_rows(MYSQL_STMT *stmt);
my_ulonglong WINAPI mysql_stmt_insert_id(MYSQL_STMT *stmt);
unsigned int WINAPI mysql_stmt_field_count(MYSQL_STMT *stmt);

my_bool WINAPI mysql_commit(MYSQL * mysql);
my_bool WINAPI mysql_rollback(MYSQL * mysql);
my_bool WINAPI mysql_autocommit(MYSQL * mysql, my_bool auto_mode);
my_bool WINAPI mysql_more_results(MYSQL *mysql);
int WINAPI mysql_next_result(MYSQL *mysql);
int WINAPI mysql_stmt_next_result(MYSQL_STMT *stmt);
void WINAPI mysql_close(MYSQL *sock);
		
*/


